package cn.piesat.sport.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;







import cn.piesat.sport.domain.Response;
import cn.piesat.sport.domain.Test;
import cn.piesat.sport.domain.link.TestParam;
import cn.piesat.sport.intf.ITest;
import cn.piesat.sport.utils.ValidatorResultHandler;

@Controller
@ResponseBody
@RequestMapping("/test")
public class testAction {
	@Resource
	private ITest testIntf;

	@RequestMapping(value = "/selectTestByPrimaryKey", method = RequestMethod.POST)
	public Response testMethod(
			@RequestBody @Validated TestParam testParam,BindingResult result){
		Response retVal = ValidatorResultHandler.handle(result);
		if(retVal == null){
			List<Test> list = testIntf.test(testParam.getId());
			if (list!=null && list.size()>0) {
				return Response.getInstance().success(list);
			} else {
				return Response.getInstance().success();
			}
		}else{
			return retVal;
		}
	}
}
